import java.io.Serializable;
import java.net.Socket;

public class Player implements Serializable {

	private String nickName; // Name of player.
	private int bet; // Players current bet.
	private int currWorth; // Amount of $$$ the player has to bet from.
	private int OriginalWorth;
	int tableNumber; // Table this player belongs to
	boolean isDealer; // Is the player a dealer
	private Card[] Cards; // The players hand
	private String State; // Player's Current State
	boolean isCurrPlayer;
	int finalCardCombinationValue;
	PlayerPosition playerPosition = null;

	// Class Constructors
	Player(String name, Card[] Cards, int tableNumber, boolean isDealer,
			boolean isCurrPlayer, PlayerPosition playerPosition) {
		this.nickName = name;
		this.bet = 0;
		this.OriginalWorth = 1000;
		this.currWorth = 1000;
		this.tableNumber = tableNumber;
		this.isDealer = isDealer;
		this.State = "active";
		this.isCurrPlayer = isCurrPlayer;
		this.finalCardCombinationValue = 9;
		this.Cards = new Card[2];
		for (int i = 0; i < Cards.length; i++)
			this.Cards[i] = Cards[i];
		this.playerPosition = playerPosition;
	}

	public void setCards(Card[] cards) {
		Cards = cards;
	}

	// Accessor Functions
	public String getName() {
		return nickName;
	}

	public int getBet() {
		return bet;
	}

	public int getCurrentWorth() {
		return currWorth;
	}

	public int getTableNumber() {
		return tableNumber;
	}

	public boolean getIsDealer() {
		return isDealer;
	}

	public boolean getIsCurrPlayer() {
		return isCurrPlayer;
	}

	public int getFinalCardCombinationValue() {
		return finalCardCombinationValue;
	}

	public void setFinalCardCombinationValue(int value) {
		finalCardCombinationValue = value;
	}

	public void setIsCurrPlayer(boolean isCurrPlayer) {
		this.isCurrPlayer = isCurrPlayer;
	}

	public Card[] getCards() {
		return Cards;
	}

	public String getState() {
		return State;
	}

	public void setState(String State) {
		this.State = State;
	}

	public void updateBetAndCurrentWorth(int raise) {
		// this method should be called after checking the bet with currHigh and
		// currWorth
		this.currWorth = currWorth - (raise - bet);
		this.bet = raise;
	}

	public void setBet(int value) {
		this.bet = value;
		this.currWorth = currWorth - value;
	}

	public void updateOriginalWorth(int value) {
		OriginalWorth += value;
	}

	public void updateCurrentWorth(int value) {
		currWorth += value;
	}

	public int getOriginalWorth() {
		return OriginalWorth;
	}
	
	public PlayerPosition getPlayerPosition() {
		return playerPosition;
	}	
}
